package com.example.demo.mapper;

import com.example.demo.pojo.dto.GoodsPageDTO;
import com.example.demo.pojo.entity.Goods;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {

    List<Goods> list(Goods goods);

    @Select("select * from goods where id = #{id}")
    Goods getById(Long id);

    @Insert("insert into goods (name, price, number, category,description, image, create_time, create_user) VALUES " +
            "(#{name},#{price},#{number},#{category},#{description},#{image},#{createTime},#{createUser})")
    void add(Goods goods);

    void batchDelete(List<Long> ids);

    void update(Goods goods);

    Page<Goods> pageQuery(GoodsPageDTO goodsPageDTO);

    @Select("select COUNT(id) from goods")
    Integer getAll();

}
